IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Machine]') AND type in (N'U'))
BEGIN
     DROP TABLE [dbo].[Machine]
END
GO

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[Machine](
     [MachineId]              [int] IDENTITY(1,1) NOT NULL,
     [PackageExecutionId]     [bigint]            NOT NULL,
     [EnabledFlag]            [tinyint]           NOT NULL CONSTRAINT [DF_Machine_EnabledFlag]  DEFAULT ((1)),
     [MachineName]            [varchar](128)      NOT NULL,
     [FQMachineName]          [varchar](255)      NOT NULL,
     [PhysicalCPUCount]       [int]                   NULL,
     [PhysicalCPUCoreCount]   [int]                   NULL,
     [LogicalCPUCoreCount]    [int]                   NULL,
     [MaxCPUSpeedMHz]         [int]                   NULL,
     [OSVersion]              [varchar](30)           NULL,
     [OSLevel]                [varchar](30)           NULL,
     [OSArchitecture]         [varchar](10)           NULL,
     [OSEdition]              [varchar](128)          NULL,
     [TotalMachineMemoryMB]   [int]                   NULL,
     [RSVDMachineMemoryMB]    [int]                   NULL,
     [ClusterVirtualNameFlag] [tinyint]           NOT NULL CONSTRAINT [DF_Machine_ClusterVirtualNameFlag] DEFAULT ((0)),
     [LastModDt]              [datetime]          NOT NULL CONSTRAINT [DF_Machine_LastModDt] DEFAULT (getdate()),
     CONSTRAINT [PK_Machine] PRIMARY KEY CLUSTERED ( [MachineId] ASC )
) ON [PRIMARY]
GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[Machine] WITH CHECK ADD CONSTRAINT [CK_Machine_RSVD] CHECK (([RSVDMachineMemoryMB]>=(512) AND [RSVDMachineMemoryMB]<[TotalMachineMemoryMB]))
GO

CREATE UNIQUE NONCLUSTERED INDEX [IX_Machine_Name] ON [dbo].[Machine] ( [MachineName] ASC ) ON [Data_Index]
GO

